// -----------------------------------------------------------------------------
// Copyright (c) 2014-2023 All rights reserved
// *********************************************************************************
// Project Name : 
// Author       : DFY
// File Name    : wallace16bit.v
// Abstract     : 16bit dinput wallace use 15 fulladder,6 levels
module wallace16bit(
  input  [13:0]  cin,
  input  [15:0]  din,
  
  output         c,
  output         s,  
  output [13:0]  cout 
);
//=================================================================================
// Signal and Parameter declaration
//=================================================================================
wire [4:0] s_level0;
wire [2:0] s_level1;
wire [2:0] s_level2;
wire [1:0] s_level3;
wire [0:0] s_level4;
//=================================================================================
// Body
//=================================================================================
full_adder level0_0_full_adder (.din(din[2:0]),   .cout(cout[0]), .s(s_level0[0]));
full_adder level0_1_full_adder (.din(din[5:3]),   .cout(cout[1]), .s(s_level0[1]));
full_adder level0_2_full_adder (.din(din[8:6]),   .cout(cout[2]), .s(s_level0[2]));
full_adder level0_3_full_adder (.din(din[11:9]),  .cout(cout[3]), .s(s_level0[3]));
full_adder level0_4_full_adder (.din(din[14:12]), .cout(cout[4]), .s(s_level0[4]));

full_adder level1_0_full_adder (.din(s_level0[2:0]), .cout(cout[5]), .s(s_level1[0]));
full_adder level1_1_full_adder (.din({s_level0[4:3],din[15]}), .cout(cout[6]), .s(s_level1[1]));
full_adder level1_2_full_adder (.din(cin[2:0]), .cout(cout[7]), .s(s_level1[2]));

full_adder level2_0_full_adder (.din(s_level1), .cout(cout[8]), .s(s_level2[0]));
full_adder level2_1_full_adder (.din(cin[5:3]), .cout(cout[9]), .s(s_level2[1]));
full_adder level2_2_full_adder (.din({cin[7:6],1'b0}), .cout(cout[10]), .s(s_level2[2]));

full_adder level3_0_full_adder (.din(s_level2), .cout(cout[11]), .s(s_level3[0]));
full_adder level3_1_full_adder (.din(cin[10:8]), .cout(cout[12]), .s(s_level3[1]));

full_adder level4_0_full_adder (.din({s_level3[1:0],cin[11]}), .cout(cout[13]), .s(s_level4));

full_adder level5_0_full_adder (.din({s_level4,cin[13:12]}), .cout(c), .s(s));
endmodule
